<template>
	<view class="content">
		<input class="uni-input" v-model="province"  placeholder="输入省份,如广东省" /><br/><br/>
		<input class="uni-input" v-model="city" placeholder="输入城市,如肇庆市" /><br/><br/>
		<button type="primary" @click="getWeather">小程序查看天气</button><br/><br/>
		<button type="primary" @click="getWeather2">云函数查看天气</button><br/><br/>
		{{result}}
	</view>
</template>

<script>
	export default {
		data() {
			return {
				province:"广东省",
				city:"肇庆市",
				result:''
			}
		},
		methods: {
			getWeather(){
				uni.request({
					url:'https://wis.qq.com/weather/common?source=pc&weather_type=observe|forecast_24h|air&province=' + this.province +'&city='+ this.city +'&county='
				,
				success: (res) => {
					            console.log(res.data);
					            this.result = JSON.stringify( res.data )
					        }})
			},
			getWeather2(){
				uniCloud.callFunction({
					name: 'jkbp-getweather',
					data: {
						// action: 'access_token',
						params: {province:this.province,city:this.city}
					}
					// ,
					// success: ({
					// 	res
					// }) => {
					// 	console.log(res);
					// 	this.result =JSON.stringify( res)
					// },
					// complete: () => {
					// 	// this.formData.captcha = false
					// }
				}).then(res => {
					console.log(res);
						this.result =JSON.stringify( res)
				});
			}
		}
	}
</script>

<style>
.content{
	padding:20rpx
}
</style>
